package com.box.app.arithmetic

interface Describable {
    fun toDescribe(isTight: Boolean = false): String
}

internal fun Iterable<Describable>.joinToDescribe(isTight: Boolean = false): String {
    return joinToString("") { it.toDescribe(isTight) }
}

internal fun Describable.toTightRange(isTight: Boolean = false): IntRange {
    val string = toDescribe(true)
    return if (isTight) {
        IntRange(0, string.length)
    } else {
        val describe = toDescribe()
        val start = describe.indexOf(string)
        IntRange(start, start + string.length)
    }
}
